<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base target="_self">
    <title>新增交费</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="新增,交费">
	<meta http-equiv="description" content="This is my page">

	<style type="text/css">
	.indexDiv
	{
		width:500px;
		height:23px;
		display:inline;
		float:left;
		border-style:solid;
		border-width:1px;
		border-color:lightblue;
		padding: 2px 2px 2px 2px;
		margin:2px 6px 8px 2px;
	}
	</style>

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'费用管理'},{'name':'交费情况'},{'name':'新增交费'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<s:hidden name="ct.id" id="tempId"></s:hidden>
    		<s:hidden name="tuition.child.id" id="childId"></s:hidden>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td width="13%" align="right" class="label">
    					收费单号：
    				</td>
    				<td width="37%" align="left">
    					待保存
    				</td>
    				<td width="13%" align="right" class="label">
    					收费日期：
    				</td>
    				<td width="37%" align="left">
    					<input type="text" name="tuition.payDate" id="payDate" style="width:120px" value="<s:property value='today' />" readonly="readonly"/>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					学童：
    				</td>
    				<td align="left">
    					<input type="text" value="<s:property value='child.childName' />" id="childNameTxt" style="width:150px" readonly="readonly"/>
    					<input type="button" value="选择" class="btn" onclick="selectChild()" />
    				</td>
    				<td align="right" class="label">
    					班级：
    				</td>
    				<td align="left">
    					<s:select name="tuition.cla.id" id="classId" list="classList" listKey="id" listValue="className" headerKey="" headerValue="--请选择--" cssStyle="width:120px"></s:select>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					收款人：
    				</td>
    				<td align="left">
    					<s:textfield name="tuition.payee" id="payee" cssStyle="width:400px;" maxLength="20" value="%{user.username}"></s:textfield>
    				</td>
    				<td align="right" class="label">
    					收款单位：
    				</td>
    				<td align="left">
    					<s:textfield name="tuition.unitName" id="unitName" cssStyle="width:400px;" maxLength="20" value="%{kinder.kgName}"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					保教费、伙&nbsp;&nbsp;<br/>
    					食费备注：
    					<br>
    					<font color="red">(40字以内)</font>
    				</td>
    				<td align="left">
    					<s:textarea name="tuition.remark" id="remark" cssStyle="width:400px; height:80px;"></s:textarea>
    				</td>
    				<td align="right" class="label">
    					代收代支&nbsp;&nbsp;<br/>
    					费用备注：
    					<br>
    					<font color="red">(40字以内)</font>
    				</td>
    				<td align="left">
    					<s:textarea name="tuition.remarkOfOther" id="remarkOfOther" cssStyle="width:400px; height:80px;"></s:textarea>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					指标：
    					<br>
   						<font color="red" style="font-size:12px">(￥为每个月的费用)</font>
    				</td>
    				<td align="left" colspan="3" id="indexTd">
    					<jsp:include page="/jsp/login/business/charge/template/chargeTemp.jsp"></jsp:include>
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="新增" class="btn" onclick="addTuition()" />
    				</td>
    			</tr>
    		</table>
    		
    	</s:form>
    </center>
    
    <script type="text/javascript">
    $(function(){
    	//从chargeTemp.jsp来
    	tempInit();
    });
    
    function addTuition()
    {
    	checkTotalAmount();
    	var indexAddDiv = $('#indexAddDiv');
    	var totalAmount = $('#totalAmount');
    	var payee = $('#payee');
    	var unitName = $('#unitName');
    	var remark = $('#remark');
    	var remarkOfOther = $('#remarkOfOther');
    	if(!isNotNull(indexAddDiv.text()))
    	{
    		showMsg('请填写至少一项费用。');
    		return;
    	}
    	if(parseFloat(totalAmount.val(), 10) <= 0)
    	{
    		showMsg('金额必须大于0。<br/><font color="red">提示：金额、开始日期与结束日期都不能为空。</font>');
    		return;
    	}
    	if(!isNotNull(payee.val()))
    	{
    		showMsg('收款人不能为空。', function(){payee.focus();});
    		return;
    	}
    	if(!isNotNull(unitName.val()))
    	{
    		showMsg('收款单位不能为空。', function(){unitName.focus();});
    		return;
    	}
    	if(remark.val().length > 40)
    	{
    		showMsg('保教费、伙食费备注不能超过40字。', function(){remark.focus();});
    		return;
    	}
    	if(remarkOfOther.val().length > 40)
    	{
    		showMsg('代收代支费用备注不能超过40字。', function(){remarkOfOther.focus();});
    		return;
    	}
    	var kgId = getTopKg();
    	var url = 'inner/charge/addTuition.action?kindergartenId=' + kgId;
    	ajaxAction(url, 'post', 'frm', true, function(result){
        	var returnObj = eval(result)[0];
        	if('success' == returnObj.result)
            {
       			var url = realPath + '/inner/charge/toUpdateTuition.action?tuition.id=' + returnObj.tuitionId + '&kindergartenId=' + kgId;
       			window.location.href = url;
           	}
        	else
        	{
        		showMsg(returnObj.message);
            }
    	});
    }
    
    function selectChild()
    {
    	var kgId = getTopKg();
    	var child = selectOneChild(kgId);
    	if(child != null)
    	{
	    	var childId = $('#childId');
	    	var childNameTxt = $('#childNameTxt');
	    	var classId = $('#classId');
	    	childId.val(child.id);
	    	childNameTxt.val(child.childName);
	    	classId.val(child.classId);
	    }
    }
    </script>
  </body>
</html>
